<?php

namespace App\Console\Commands;

use App\Lead;
use Illuminate\Console\Command;

class LeadCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'lead:filter';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '柯文甜';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        Lead::where('create_time','>',strtotime('2020-09-01 00:00:00'))
            ->where('create_time','<',strtotime('2020-09-16 00:00:00'))
            ->where('is_transform',0)
            ->where('owner_user_id',15)
            ->chunkById(100,function ($leads){
                foreach ($leads as $lead){
                    $lead->project_id=10;
                    $lead->save();
                }
            });
    }
}
